package org.csu.jpetstore.service;

import org.csu.jpetstore.domain.Item;
import org.csu.jpetstore.persistence.CartDAO;
import org.csu.jpetstore.persistence.impl.CartDAOImpl;

import java.util.List;

public class CartService {
    CartDAO cartDAO;

    public CartService() {
        cartDAO = new CartDAOImpl();
    }

    public void addItem(Item item, String username) {
        cartDAO.addItemToCart(item, username);
    }

    public void updateQuantities(Item item, int num, String username) {
        cartDAO.updateCartQuantities(item, num,username);
    }

    public List<String> getItemList(String username) {
        return cartDAO.getItemList(username);
    }

    public List<String> getOrder(int orderid) {
        return cartDAO.findOrder(orderid);
    }

    public int itemNum(String itemId, String username) {
        return cartDAO.itemNumber(itemId,username);
    }

    public void subimt(String username, int orderid) {
        cartDAO.submitCart(username,orderid);
    }

    public void delete(Item item, String username) {
        cartDAO.remove(item,username);
    }

}
